#include<iostream>
using namespace std;
int num[100];
void fun(int front,int rear){
    if(front>=rear)return;
    int i=front,j=rear,k=num[front];
    while(i<j){
        while(i<j&&num[j]>=k)
            j--;
        if(i<j)num[i++]=num[j];
        while(i<j&&num[i]<k)
            i++;
        if(i<j)num[j--]=num[i];
    }
    num[i]=k;
    fun(front,i-1);
    fun(i+1,rear);
}
int main(){
    int n=20;
    for(int i=0;i<n;i++){
        num[i]=rand()%201-100;
        cout<<num[i]<<" ";
    }
    cout<<endl;
    fun(0,n-1);
    for(int i=0;i<n;i++)
    cout<<num[i]<<" ";
}